<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>廉政告知书（全局）</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style type="text/css">
        .layui-input layui-unselect {
            cursor: pointer;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="layui-tab table_div">
                        <div class="layui-form-item">
                            <div class="layui-input-inline">
                                <input type="text" readonly class="layui-input" id="createTime" placeholder="填写时间">
                            </div>
                            <div class="layui-input-inline layui-form">
                                <input type="text" class="layui-input" id="ajbh" placeholder="案件编号">
                            </div>
                            <div class="layui-input-inline layui-form">
                                <input type="text" class="layui-input" id="nsrmc" placeholder="纳税人名称">
                            </div>
                            <div class="layui-input-inline layui-form">
                                <input type="text" class="layui-input" id="nsrsbh" placeholder="纳税人识别号">
                            </div>
                            <button class="layui-btn" onclick="search()" id="search">查询</button>
                        </div>
                        <table class="layui-table" id="showTable" lay-filter="showTable"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/html" id="tool1">
    <a class="layui-btn layui-btn-xs" lay-event="save">保存</a>
</script>

<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>

<script th:inline="none">
    // 获取token
    var token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var showTable;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    var element = layui.element;
    var maxlength = 500;
    var inspectionMan = "";
    var mold = "";
    var contentdate = null;
    var startTime = null;
    var endTime = null;
    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {
        //创建时间
        laydate.render({
            elem: '#createTime'
            , type: 'datetime'
            , range: '~'
            , done: function (value, date, endDate) {
                if (value !== null && value !== undefined && value !== "") {
                    startTime = value.split("~")[0];
                    endTime = value.split("~")[1];
                } else {
                    startTime = null;
                    endTime = null;
                }
            }
        });
        showTable = table.render({
            elem: '#showTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true, // 开启分页
            url: '/workflow/notification/list',//数据接口
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },
            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'jcajxxuuid',
                    title: '稽查UUID',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 140,
                    field: 'notificationNo',
                    title: '廉政编号',
                    edit: "text",
                    sort: true,
                }, {
                    align: 'center',
                    width: 205,
                    field: 'jcajbh',
                    title: '稽查案件编号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 210,
                    field: 'nsrsbh',
                    title: '纳税人识别号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 280,
                    field: 'nsrmc',
                    title: '纳税人名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 200,
                    field: 'field6',
                    title: '税务检查通知书送达情况',
                    sort: true,
                },
                // {
                //     align: 'center',
                //     width: 200,
                //     field: 'wsdyy',
                //     title: '税务廉政告知书送达情况',
                //     edit: "text",
                //     sort: true,
                // }, {
                //     fixed: 'right',
                //     align: 'center',
                //     width: 125,
                //     toolbar: "#tool1",
                //     title: '操作'
                // }
            ]],
            toolbar: '#toolbar',
            done: function () {
                // 可以监听编辑完成事件
                table.on('edit(showTable)', function (obj) {
                    const value = obj.value; // 获取编辑后的值
                    const id = obj.data.id;   // 获取当前行数据
                    const field = obj.field; // 获取编辑的字段名
                    let notificationNo;
                    let wsdyy;
                    // 如果是廉政编号的编辑，需要处理相应的更新逻辑
                    if (field === 'notificationNo') {
                        // 这里可以处理廉政编号的更新逻辑
                        notificationNo = value;
                    } else if (field === 'wsdyy') {
                        // 这里可以处理未送达原因的更新逻辑
                        wsdyy = value;
                    }
                    const mapArr = {
                        "id": id,
                        "notificationNo": notificationNo,
                        "wsdyy": wsdyy
                    };
                    CoreUtil.sendPost("/workflow/notification/saveLzgzs", mapArr,
                        function (res) {
                            if (res.code === 0) {
                                layer.msg("保存成功！");
                                search();
                                return false;
                            } else {
                                layer.msg(res.msg);
                                return false;
                            }
                        });
                });
            }
        });
        // 列操作
        table.on('tool(showTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'save':
                    window.open(data.notificationFile, '_blank');
                    break;
            }
        });
        // 返回
        $("#btn_cancel").click(function () {
            back();
            return false;
        });
    });

    //查询
    function search() {
        showTable.reload({
            where: {
                startTime: startTime,
                endTime: endTime,
                ajbh: $("#ajbh").val(),
                nsrmc: $("#nsrmc").val(),
                nsrsbh: $("#nsrsbh").val()
            },
            page: {
                curr: 1
            }
        });
    }

</script>

</body>
</html>